module led_flash#(
    parameter FLASH_PERIOD = 50_000_000		//LED闪烁周期
)
(
    input sys_clk,
    input sys_rst_n,
    
    output reg led
);

//周期计数器
reg [31:0] count;

//进行周期计数
always @(posedge sys_clk) begin
	if(!sys_rst_n)
    	count <= 32'd0;
    else if(count < (FLASH_PERIOD - 1))
    	count <= count + 32'd1;
   	else
        count <= 32'd0;
end

//在计数周期结束时控制LED翻转
always @(posedge sys_clk) begin
	if(!sys_rst_n)
    	led <= 1'b0;
    else if(count == (FLASH_PERIOD - 1))
    	led <= ~led;
end

endmodule
